package com.coursehub.course.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

/**
 * 章节实体
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "chapter")
public class Chapter {
    
    @Id
    @Column(name = "chapter_id", nullable = false, length = 100)
    private String chapterId;
    
    @Column(name = "chapter_name", nullable = false, length = 100)
    private String chapterName;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JoinColumn(name = "course_id", nullable = false)
    private Course course;
    
    @Column(name = "course_id", insertable = false, updatable = false)
    private String courseId;
}